from binascii import unhexlify

base_url = 'https://gitee.com/mouxangitee/hack-sxos/attach_files/'

bootori = 'boot_ori.dat'
dist = 'dist'
boot = dist+'/boot.dat'
Licence = dist+'/license.dat'
Request = 'license-request.dat'
GFXSXOS = 'GFX_sxos.exe'

bootbin = dist+'/boot.bin'
header = dist+'header.bin'
header_s3 = dist+'header_s3.bin'
stage2 = dist+'stage2_40008100.bin'
stage3 = dist+'stage3_40020000.bin'
payload81 = dist+'payload_81000000.bin'
payload90 = dist+'payload_90000000.bin'
payload98 = dist+'payload_98000000.bin'
payloadA0 = dist+'payload_A0000000.bin'
payloadA0_dec = dist+'payload_A0000000_dec.bin'
payloadA0_dec2 = dist+'payload_A0000000(dec2).bin'
payloadA0_enc = dist+'payload_A0000000_enc.bin'
rommenu = dist+'rommenu.bin'
bootloader = dist+'bootloader_88000000.bin'
assets = dist+'assets_8804A000.bin'
fb = dist+'fb_F0000000.bin'

goodlic = ("B2ECDB5F517EDB111D906C8D153AEFFCE6D17282E9955116600EBBAE4770FA21A33A78CB5FCB7A9431D6D9CE20B02879E84D899310F2F59ABD716143A5381A53D55944E37EECFE166AEA6FA334469CDDF868F99509C6D95CCFC0B9DB63F8377DD6E833E8989F7C20FFED34F4F0AF054D60C28455E6933C5158F4F72E8C44C9F695E5EFAD756FF3A8D3CCF1633AC72AFB5E53CFE3ECBE25E31FA49FD6397D75E5DF38EC61DC897E02D1A44613B8A4359FB0292D95173BDF96B5AE5D8EEF821B1CFB6AEFA759E0A51EBD083C3CD751B5E2EA20201EAC2A19AE37712036DF4E7A05A1DE757FA5F5B440BA303A477063D9D2957EE71FA370217532684BA1E55C097D")
padding = ("0001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000000")
pub_key = ('ef5d659c147718b4ff06aa9e04e9fb324f163f1f66d58cc0f904138e365cefc7462fbc907947c7208c75b87e75274f9b5ffe62b5c5269c9ab272ec5f949827dcd1a243ed87d4bdd4a747033f79eb54d6a1256377b4ba0fc7b1f1edcc4380ebe22338969542c6a06df1349a4d26794a3b4657ccef35abf54b11d8bc574a5ff7b0f8bc51eab6d143de2b98c5f8939e8a32c6076c55e7f3c43f5b27cc34fdeaff9293f7e841d6e18f081bd7620cab651f5bca1afca4d1479435fada06df81591abcbe0629ba6df3a46320d44d40fe5a40678063c1c6452b65132a0326ac8e118ef0e084f65a7f888070e522a9f63eaf862436255a7f8f9c4b3009033860c7fb637b')
pub_exponent = int('10001', 16)
priv_key =     int('cca180cb552797c4ac3d2bc1599c1a76a0ebf8dcc4920df9af28cffb04f8a0b8308580e3d5fb09fe0676615a22978fd3d9d5e4d7568b32d881740425962819f40a777930e8ad73f807658b1e4a01688ef046c16945e4c6b6c6a677cfe769a0bebbb395f0569cedebef8833dd7ee5b4134688ab17593fffbcc4ae101d63e4f51efbd207299630a760b1fb55e5170def77d1a729a5211de352dfbcf8dda39f09b5e5cfca53dd03c74ec792e382c17c2132af8b6632bb801c9a3de9a541414cfd5065323983cf6bfd69abce7505165e6184a8c57eba35f37db39f080489f662c005263c4cabc3948bb5852c8454cff7388ab47023b3dbe8dc0536d07df404d58591', 16)
patch_d = unhexlify("3B980014")
patch_spoof = unhexlify("0000014A8D2981520D40B072AE0D40390F008052DF010F6B01F8EC54010000140A208CD28A23B0F24B3140A90D2881D20D40B0F2AB3100A9B867FF17")
payload81_key = unhexlify("12280A64B7A487E99864CD2E22393C87")
payload81_ctr = unhexlify("C28124EAA147BEE8EF865E2AE8496834")
s2_key = unhexlify("47E6BFB05965ABCD00E2EE4DDF540261")
s2_ctr = unhexlify("8E4C7889CBAE4A3D64797DDA84BDB086")
s3_key = unhexlify("D548D48DBA299604CED1AE5B47D8429C")
s3_ctr = unhexlify("428DB51A85E4940D37648FEC66BA2C78")
fw_key = unhexlify("81F555CC58EF03CB41BD81C90A8E8F79")
fw_ctr = unhexlify("A4C122884E6C8979E3E3E0F07D116E52")
payloadA0_key = unhexlify("043AB07482B9A8B55EA9041C74CD92EB")
payloadA0_ctr = unhexlify("AAF5295AEC233F953B408EE27F892CF8")
payload90_key = unhexlify("95F4D1F3C1EC6E5A54AC70F49AE315F5")
payload90_ctr = unhexlify("DCD96167060A7A9E1F2BC8C1C2A611B4")
payload98_key = unhexlify("DEE47F27900D540AFE04C4063638CE0F")
payload98_ctr = unhexlify("467E7F219FDCAFA5E6187262755D4DFC")
bootloader_key = unhexlify("FB61357AB9DEE1C9D4C49F6488349EF0")
bootloader_ctr = unhexlify("5BCF60493E61BCB930FD44C7FAC0EE09")
assets_key = unhexlify("EF48639FC925C8D0364B2DA7614EB038")
assets_ctr = unhexlify("7298408E70FBE048DCC6E594B0C272B6")
fb_key = unhexlify("4599F62BF51E62B6AC05AAA7E7B03DE3")
fb_ctr = unhexlify("39B0F6E0846C53DCE0457F285797AE99")
KEYXOR = ("FEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFE")
RET0 = unhexlify("00008052C0035FD6")
NOP = unhexlify("1F2003D5")
END = unhexlify("00")